{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "BERT_model_INDEP = keras.models.load_model('EI dataset train 5fold/5fold/BERT-BFD_best_model.epoch03-loss0.19.hdf5')\n",
    "X_test = load_INDEP_X_data('BERT_BFD')\n",
    "BERT_mod_pred = BERT_model_INDEP.predict(X_test, batch_size=8)\n",
    "print(BERT_mod_pred)\n",
    "file = open('EI dataset train 5fold/5fold/result.txt', 'a')\n",
    "for i in range(len(BERT_mod_pred)):\n",
    "    # 去除[]\n",
    "    mid = str(BERT_mod_pred[i]).replace('[', '').replace(']', '')\n",
    "    # 删除单引号并用字符空格代替逗号\n",
    "    mid = mid.replace(\"'\", '').replace(',', '') + '\\n'\n",
    "    file.write(mid)\n",
    "file.close()\n",
    "BERT_mod_pred_labels = convert_preds(BERT_mod_pred)\n",
    "print(BERT_mod_pred_labels)\n",
    "file = open('EI dataset train 5fold/5fold/result(label).txt', 'a')\n",
    "for i in range(len(BERT_mod_pred_labels)):\n",
    "    # 去除[]\n",
    "    mid = str(BERT_mod_pred_labels[i]).replace('[', '').replace(']', '')\n",
    "    # 删除单引号并用字符空格代替逗号\n",
    "    mid = mid.replace(\"'\", '').replace(',', '') + '\\n'\n",
    "    file.write(mid)\n",
    "file.close()\n",
    "\n",
    "BERT_metrics = display_conf_matrix(y_test_INDEP, BERT_mod_pred_labels, BERT_mod_pred, 'BERT Model', 'Validation/ADAPTABLE/BERT(LM)_Model_CM.png')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
